<template>
	<view>
		<!-- 分段器 -->
		<zy-segmented :values="items" :current="current" @onClickItem="onClickItem" />
		<!-- 待领取 -->
		<unreceived :formList="unreceivedList" v-if="current==0" />
		<!-- 待处理 -->
		<undeal :formList="undealList" v-if="current==1" />
		<!-- 已处理 -->
		<dealed :formList="dealedList" v-if="current==2" />
	</view>
</template>

<script>
	import {
		queryQuestionList
	} from "@/api/homepage.js"
	import unreceived from './components/unreceived.vue'
	import undeal from './components/undeal.vue'
	import dealed from './components/dealed.vue'
	export default {
		components: {
			unreceived,
			undeal,
			dealed
		},
		data() {
			return {
				items: [this.$t('homepage.CallDeal.unreceive'), this.$t('homepage.CallDeal.undeal'),
					this.$t('homepage.CallDeal.dealed')
				], //分段器名称
				current: 0, //分段器默认初始值
				unreceivedList: [],
				undealList: [],
				dealedList: [],
			}
		},
		onPullDownRefresh() {
			setTimeout(function() {
				uni.redirectTo({
					url: "/pages/HomePage/CallDeal/index"
				})
				uni.stopPullDownRefresh();
			}, 1000);
		},
		onLoad(val) {
			console.log(val)
			if (val.data == "unreceive") {
				this.current = 0
			} else if (val.data == "undeal") {
				this.current = 1
			}
			var _this = this
			_this.queryQuestion()
			uni.$on('callDeal', function() {
				_this.queryQuestion()
			})
		},
		onUnload() {
			// 移除监听事件      
			uni.$off('callDeal')
		},
		methods: {
			// 分段器选项发生改变时触发
			onClickItem(index) {
				this.current = index;
			},
			queryQuestion() {
				this.unreceivedList = []
				this.pendingInfo = []
				this.processedInfo = []
				queryQuestionList({
					billStatus: 0,
				}).then((res) => {
					this.unreceivedList = res.data
				})
				queryQuestionList({
					billStatus: 1,
				}).then((res) => {
					this.undealList = res.data
				})
				queryQuestionList({
					billStatus: 2,
				}).then((res) => {
					this.dealedList = res.data
				})
			},
		}
	};
</script>
<style lang="scss" scoped>
</style>